package Java8实战._3_Stream_用流收集数据._2_归约和汇总;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class _4_广义的归约汇总_收集与归约 {

    public static void main(String[] args) {

        Stream<Integer> integerStream = Arrays.asList(1, 2, 3, 4, 5, 6).stream();

        integerStream.reduce(
                                new ArrayList<Integer>(),
                                (List<Integer> l, Integer e) -> {
                                    l.add(e);
                                    return l;
                                },
                                (List<Integer> l1, List<Integer> l2) -> {
                                    l1.addAll(l2);
                                    return l1;
                                }
        );
    }
}

















